package com.apes.scm.masterdata.area.model;

import com.apes.framework.jpa.ApesBean;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;
import java.io.Serializable;

/**
 * 功能：区域信息
 *
 * @author xul
 * @create 2018-06-11 11:03
 */
@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Area.CONST_TABLE_NAME)
public class Area implements ApesBean, Serializable {
    public static final String CONST_TABLE_NAME = "mas_area";

    @Id
    @Column(name = "id", length = 20)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "区域信息")
    private String id;

    @Column(name = "name", length = 60, nullable = false)
    private String name; //名称

    @Column(name = "parent_id", length = 20)
    private String parent; //名称
    @Column(name = "groups", length = 6)
    private String group; //分组

    @Column(name = "initials", nullable = false)
    @Comment("拼音码")
    private String initials;

//    @ManyToOne(cascade = CascadeType.ALL)
//    @JoinColumn(name = "parent_id")
//    private Area parent;

//    @OneToMany(mappedBy = "parent", cascade = CascadeType.ALL, fetch = FetchType.LAZY)
//    private Set<Area> children;
}
